package org.dtrd.modules.questionnaire.entity.bean;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchivePhysical;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveBasic;
import org.dtrd.modules.patient.entity.po.DtrdEntRdPatient;
import org.dtrd.modules.questionnaire.entity.po.DtrdEntQuestionnaireRdLifeway;

/**
 * <p>
 * 
 * </p>
 *
 * @author QR
 * @since 2022-03-01
 */
@Getter
@Setter
@ApiModel(value = "详情")
public class QuestionnaireLifewayDetail {

    private Integer dataId;

    @ApiModelProperty("患者id")
    private Integer patientId;

    @ApiModelProperty("名字")
    private String name;

    @ApiModelProperty("电话")
    private String phone;

    @ApiModelProperty("年龄")
    private Integer age;

    @ApiModelProperty("性别, 1-男, 2-女")
    private Integer sex;

    @ApiModelProperty("身高")
    private Float height;

    @ApiModelProperty("体重")
    private Float weight;

    @ApiModelProperty("婚姻状况, 1-已婚, 2-未婚")
    private Integer maritalStatus;

    @ApiModelProperty("教育状况")
    private Integer educationStatus;

    @ApiModelProperty("收入情况")
    private Integer incomeStatus;

    @ApiModelProperty(value = "问卷选项", notes = "选项A/B/C/D用逗号连接成字符串")
    private String input;

    @ApiModelProperty("得分")
    private Integer score;

    @ApiModelProperty("结果")
    private String result;



    public QuestionnaireLifewayDetail parseFromPO(DtrdEntQuestionnaireRdLifeway po) {
        dataId = po.getDataId();
        input = po.getInput();
        score = po.getScore();
        result = po.getResult();
        return this;
    }

    public QuestionnaireLifewayDetail parseFromPO(DtrdEntRdPatient po) {
        patientId = po.getDataId();
        phone = po.getPatientsMobile();
        name = po.getPatientsName();
        if (po.getPatientsBirthday() != null) {
            age = DateUtil.ageOfNow(po.getPatientsBirthday());
        }
        sex = po.getPatientsSex();
        return this;
    }

    public QuestionnaireLifewayDetail parseFromPO(DtrdEntRdArchivePhysical physical) {
        height = physical.getHeight();
        weight = physical.getWeight();
        return this;
    }

    public QuestionnaireLifewayDetail parseFromPO(DtrdEntRdArchiveBasic basic) {
        maritalStatus = basic.getMaritalStatus();
        educationStatus = basic.getEducation();
        if (NumberUtil.isNumber(basic.getIncome())) {
            incomeStatus = Integer.parseInt(basic.getIncome());
        }
        return this;
    }
}
